// 加载React
import React from 'react'
// 加载Component
import { Component } from 'react'

import styles from './defaultStyle.less'
import {queryUserDetailText} from './defaultServ'
import { config } from '../../utils'
import Cookie from 'js-cookie'
import { delCacheUser } from 'widget/Layout/Banner/BannerServ'
import { messageInform } from 'utils/notification'
import { hashHistory } from 'dva/router'
import { customLoginRedirect } from 'utils/redirect_utils'

import build from '../../assets/img/home/icon/build.png'
import wenjuan from '../../assets/img/home/icon/wenjuan.png'
import zhengce from '../../assets/img/home/icon/zhengce.png'
import quanxian from '../../assets/img/home/icon/quanxian.png'
import yunwei from '../../assets/img/home/icon/yunwei.png'
import yonghu from '../../assets/img/home/icon/yonghu.png'
import shezhi from '../../assets/img/home/icon/shezhi.png'

// 导出组件
export default class extends Component {
  // 构造函数
  constructor(props, context) {
    super(props, context)
    this.state = {
      homeInfo:{
        // formationUpdate: '',
        // activityUpdate: '',
        // bookingRoom: '',
        // eventRegistration:'',
        // applyCooperation:''
      }
    }
    // this.queryUserDetailText()
    
  }
  
  // 执行退出
  async queryUserDetailText() {
    let self = this
    // if (!config.isLogin) {
    // }
    // 注销登录
    let { success,msg } = await queryUserDetailText({
      // userType: 1
    })
    
    if (success) {

    }
  }

  queryMenuRoot(id){
    let ulRoot = document.querySelector("#MenuJsxInline").querySelector("ul")
    let list = ulRoot.querySelectorAll("li")
    list.forEach(it =>{
      let link =  it.getAttribute("data-link")
      if(id == link){
        it.click()
      }
    })
  }
  
  //准备：即将被重新渲染，状态未变化
  componentWillMount() {
  }

  //准备：即将被重新渲染，状态未变化
  componentWillUpdate(nextProps, nextState) {}

  //完成：正在被重新渲染，状态已变化
  componentDidUpdate(prevProps, prevState) {}

  // 已加载组件，收到新属性时调用
  componentWillReceiveProps(nextProps) {}

  // 已插入真实DOM
  componentDidMount() {}

  //组件将被卸载
  componentWillUnmount(){}

  // 初始状态或状态变化会触发render
  render(ReactElement, DOMElement, callback) {
    let homeInfo = this.state.homeInfo
    const userName = Cookie.get(config.cookie.userName);
    return (
      <div className={styles.welcome}>
        <div className={styles.boxContainer}>
          <div className={styles.boxItem}  onClick={(e) =>{
            this.queryMenuRoot('buildingAdmin')
            hashHistory.push("/home/buildingAdmin/baseinfo")
            }}>
            <img src={build} width={80} height={80} />
            <span>楼盘管理</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('questionnaireManage')
            hashHistory.push("/home/questionnaireManage/questionnaire")
            }}>
            <img src={wenjuan} width={80} height={80} />
            <span>问卷调查</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('infoAdmin')
            hashHistory.push("/home/infoAdmin/infoList")
            }}>
            <img src={zhengce} width={80} height={80} />
            <span>政策资讯</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('advertisementAdmin')
            hashHistory.push("/home/backStageAdmin/userList")
            }}>
            <img src={quanxian} width={80} height={80} />
            <span>广告管理</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('backStageAdmin')
            hashHistory.push("/home/backStageAdmin/userList")
            }}>
            <img src={quanxian} width={80} height={80} />
            <span>权限管理</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('backStageAdmin')
            hashHistory.push("/home/itOperations/changmobileapply")
            }}>
            <img src={yunwei} width={80} height={80} />
            <span>运维管理</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('accountAdmin')
            hashHistory.push("/home/accountAdmin/accountList")
            }}>
            <img src={yonghu} width={80} height={80} />
            <span>账户管理</span>
          </div>
          <div className={styles.boxItem} onClick={(e) =>{
            this.queryMenuRoot('setCenter')
            hashHistory.push("/home/setCenter/updateDescSetting")
            }}>
            <img src={shezhi} width={80} height={80} />
            <span>系统设置</span>
          </div>
        </div>
      </div>
    )
  }
}
